POV-Ray : Newsgroups : povray.general : Particles 101 : Re: Particles 101 Server Time
6 Aug 2024 12:22:32 EDT (-0400)
  Re: Particles 101  
From: Mark Lewin
Date: 21 Mar 2002 22:38:37
Message: <3C9AA765.EEFD3B57@yahoo.com.au>
Mark Hanford wrote:

> global_settings{waffle on}
>
> Okay, so I've made a start on my particle system, but would like a couple of
> pointers (or even cheeky samples).  Here's what I've got so far...
>
> Make Some Particles (on first frame):
>     pos1=rand(...)
>     velocity1=rand(...)
>     force1=0
>     mass1=1
> do for each frame_number
>     Load Particle Data (pos, velocity, force, mass, ...extras...)
>     Draw The Particles

I tend to draw the particles last, but so long as you are consistent...

>
>     Calculate New Positions
>     Save Particle Data
> next frame_number
>
> Now this seems like a logical choice of steps, so I assume (?) my troubles
> are with the calculations.  It must have taken even Him some time to get the
> rules right...
>
> The only interaction I'm looking at is the attraction due to each of the
> other particles, with BigG being a guess for this system:
> //newforce = oldforce + direction*(Universal Gravitation)
> #declare force1 = force1 +
>     vnormalize(pos2-pos1) * ((BigG * mass1 * mass2) / vlength(pos2-pos1)^2);

I hope you set each particle's force to <0,0,0> before accumulating the
gravitational forces from the other particles. The total force should not
accumulate between time steps, it should be evaluated at each time step only.

>
>
> which should give me a nice force pulling the particle around, yes?  This is
> where I kind of "made it up" to get something that looked like it works:
> #declare velocity1 = velocity1+force1;  //first leap of faith
> #declare pos1 = pos1+velocity1;  //second leap of faith
>

Note that...

velocity = velocity + acceleration*timestep;

and...

acceleration = Force / mass;

Because you have mass = 1, this does not matter, but think of what should happen
when mass != 1.

Note too that the timestep should be small (really small) for a good simulation.
This may mean performing more than one set of position calculations per frame of
animation; for my mini solar system anim, I think I used eight itterations per
frame.

From the looks of it, you are only performing one itteration per frame, so you
might want to try more.

>
> Now while this can create some quite nice animations, it seems heavily
> dependent on correct settings for BigG with relation to ParticleCount and
> mass.
> So, is this to be expected?

Your BigG is scaling your force, so you should expect BigG to make a big
difference. And, the more particles you have, the more forces from neighbours
each individual particle will experience.

Note that BigG in Newtonian physics = 6.67 x 10-11 Nm2/kg2 regardless of the
number of bodies (particles) in the system. My tip is to stick to one BigG value
and adjust the mass of the particles.

> Particles either achieve escape velocity
> immediately, or clash together and head off together into the distance.

> Any help greatfully received, although just putting all this down in words
> seems to help sometimes too ;)

Good luck with it. I'm sure others will be able to give you a better explaination
than myself.

MJL


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.